<?php
$taskId = $_GET['task_id'] ?? '';
$dns = "sqlsrv:Server=LAPTOP-LD8O4C6L\SQLEXPRESS;Database=TaskManagement";
$db = new PDO($dns,"sa","123456");
$sql = "select * from TaskList where TaskId = {$taskId}";
$result = $db->query($sql);
$taskInfo = $result->fetch(PDO::FETCH_ASSOC);

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>任务详情</title>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script src="js/jquery.js"></script>
</head>
<body>
<div id="container">
    <a href="task_list.php">返回任务列表</a>
    <form method="post" action="detail_save.php">
        <table class="update">
            <caption>
                <h3>任务详情</h3>
            </caption>
            <tr>
                <td>任务名称：</td>
                <td><?php echo $taskInfo['TaskName']?></td>
            </tr>
            <tr>
                <td>任务状态：</td>
                <td><?php
                    if ($taskInfo['TaskStatus']==1){
                        echo '新创建';
                    }else if($taskInfo['TaskStatus']==2){
                        echo '进行中';
                    }else if ($taskInfo['TaskStatus']==3){
                        echo '已完成';
                    }else{
                        echo '未知';
                    }
                    ?></td>
            </tr>
            <tr>
                <td>任务内容：</td>
                <td><textarea cols="60" rows="15"
                              readonly="readonly"> <?php echo $taskInfo['TaskContent'] ?> </textarea></td>
            </tr>
            <tr>
                <td> </td>

                <td>

                      <a class="update_ing" onclick="return confirm('标记为进行中？')" href="detail_save.php?task_id=<?php echo $taskInfo['TaskId']?>">
                          <?php if ($taskInfo['TaskStatus']!=2){
                          echo '标记为进行中';
                          }
                          ?></a>
                    <a onclick="return confirm('标记为已完成？')" href="status.php?task_id=<?php echo  $taskInfo['TaskId']?>">
                        <?php if ($taskInfo['TaskStatus']!=3){
                            echo '标记为已完成';
                        }
                        ?></a>

                </td>

            </tr>

        </table>
    </form>
</div>
<script src="js/main.js"></script>
</body>
</html>

